const axios = require("axios")


const request = axios.create({
    headers:{
        'Content-Type': 'application/x-www-form-urlencoded',
        'origin': 'https://www.kugou.com',
        'referer': 'https://www.kugou.com/',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'
    }
});
async function get (url,data){
    data = data? data : "";

    return new Promise((resolve,reject) => {
        request({
            url:url,
            method:'get',
            params:data
        }).then((r) => {
            resolve(r.data)
        }).catch((r) => {
            reject({code:500})
        })
    })

}
async function post (url,data){
    data = data? data : "";
    return new Promise((resolve,reject) => {
        request({
            url:url,
            method:'get',
            params:data
        }).then((r) => {
            resolve(r.data)
        }).catch((r) => {
            reject({code:500})
        })
    })
}
module.exports = {get,post}